package biblioteca;

import java.io.IOException;
import java.sql.*;

/**
 * @author Gabriel
 */
public class login {
    
    public boolean logar (String login, String pwd) throws IOException, SQLException{
        acessoBanco bd = new acessoBanco();
        bd.conectar();
        String query = "select login, senha from funcionario where login ='"+login+"' and senha='"+pwd+"'";
        PreparedStatement stm = bd.conn.prepareStatement(query);
        ResultSet rs = stm.executeQuery(query);
        if(rs.next()){
            return true;
        }else{
            return false;
        }
    }
    public void criarUser (Usuario user) throws SQLException, IOException{
       acessoBanco bd = new acessoBanco();
       bd.conectar();
       String query ="insert into usuario (nome, dataNasc, cpf, ci) values ('" + user.getNome() + "'," + user.getDataNasc()+ "," + String.valueOf(user.getCpf())+","+String.valueOf(user.getCi())+")";
       PreparedStatement stm = bd.conn.prepareStatement(query);
       stm.executeUpdate();
       
    }
}
